package com.nulldev.util.fileformats.ftf;

import java.io.File;

import com.nulldev.util.crypto.encryptAPI.manage.EncryptAPI;
import com.nulldev.util.fileformats.ftf.FTFReader.EncryptionType;
import com.nulldev.util.io.FileUtil;
import com.nulldev.util.io.MD5Utils;
import com.nulldev.util.string.StringsUtil;

public class FTFEncoder {

	public static void main(String[] args) throws Exception {
		final String d = FileUtil.readFileToString(FileUtil.getResourceAsFile(FTFEncoder.class, "[redacted]"));
		final String p = StringsUtil.generateSecure(32);
		System.out.println("Password: " + p);
		final String t = "[redacted]";
		final String va = EncryptAPI.getEncryptorForEncryption("XXTEA").encrypt(t, p);
		//System.out.println("Data: " + va);
		System.out.println("Hash: " + MD5Utils.getMD5Hex(va));
		final FTFDocument cd = new FTFDocument(t);
		final File x = FileUtil.safeCreate("[recated]" + StringsUtil.generateSecure(10) + ".ftf");
		System.out.println("File: " + x.toString());
		cd.writeDocumentToFile(x,
				p, EncryptionType.XXTEA, FTFMetadata.DATE_OF_CREATION);
	}

}
